package com.dhy.handler;

import java.io.File;

/**
 * @author 大忽悠
 * @create 2022/5/27 10:13
 */
public abstract class AbstractImgHandler implements ImgHandler{
    private static File localFile;
    private static File tempFile;
    private static final String TEMP_SUFFIX=".temp";

    @Override
    public Boolean preHandle(String localFilePath) {
        if(localFile==null){
            localFile = new File(localFilePath);
            if (!localFile.exists()) {
                throw new IllegalArgumentException(localFilePath + "不存在");
            }
        }
        if(tempFile==null){
            tempFile = new File(localFilePath + TEMP_SUFFIX);
        }
        return true;
    }

    @Override
    public File getLocalFile() {
        return localFile;
    }

    @Override
    public File getTempFile() {
        return tempFile;
    }
}
